package com.abc.robot01.vivemodel

import android.util.Log
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.abc.robot01.retrofit.RetrofitService
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch


class BaoJiaViewModel : ViewModel() {
    val TAG = "报价ViewModel"
    val show =  mutableStateOf(true)
    var sliderPosition  =   mutableStateOf(0f)
    var renderConfigId  =   mutableStateOf("")
    var sliderPosition2  =   mutableStateOf(0f)
    var price  =  mutableStateOf<RetrofitService.Zh>(RetrofitService.Zh())

    //客户列表
    private val _customerList = MutableStateFlow<List<RetrofitService.RenderItem>>(emptyList())
    val customerList: StateFlow<List<RetrofitService.RenderItem>> = _customerList

    fun  load(){
        viewModelScope.launch {
            val a = RetrofitService.instance.getDesignPrices(
                renderConfigId = renderConfigId.value,
                accessToken = Robot.accessToken,
                userId = Robot.userId,
                companyId = Robot.companyId,
            )
            price.value = a.data.zh
            Log.e(TAG, "报价信息:$a")
        }
    }

}

